<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>周记实管理-编辑周记实</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>

    <link rel="shortcut icon" href="favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="static/css/font.css">
    <link rel="stylesheet" href="static/css/xadmin.css">
    <link rel="stylesheet" href="static/lib/layui/css/layui.css">


    <style type="text/css">
        .layui-table th {
            text-align: center;
            font-weight: bold;
            min-width: 300px;
            max-width: 100px;
            border-style: solid;
            border-radius: 2px
        }
        .layui-table td {
            height: auto;
            line-height: 20px;
            padding: 0 10px;
            overflow: hidden;
            text-overflow: ellipsis;
            box-sizing: border-box;
            white-space: normal;   //nowrap=不换行   normal=正常
        }
    </style>

</head>
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a >首页</a>
        <a >周记实管理</a>
        <a>
          <cite>周记实编辑</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body layui-anim layui-anim-up">
    <form class="layui-form" action="">
    <input type="hidden" id="eId" name="eId" />
    <input type="hidden" id="wId" name="wId" />
    <input type="hidden" id="wwId" name="wwId" />
    <table class="layui-table">
        <thead>
        <tr>
            <th>周记实编辑</th>
            <th  style="color: #FF0000;">岗位工作任务</th>

        </tr>
        </thead>
        <tbody id="view">
        <tr>
            <td id="weekGwzz">
                <!--日常工作-->
                <div class="layui-form-item">
                    <label  class="layui-form-label layui-required" >日常工作</label>
                    <div class="layui-input-block" style="width: 666px;">
                        <textarea type="text" style="width:666px!important;" name="weekInfo" id="weekInfo" value="" lay-verify="" autocomplete="off" placeholder="请输入日常工作内容"  class="layui-textarea"></textarea>
                        <!-- <input style="width:500px!important;" name="weekInfo" id="weekInfo" value=""  type="text" lay-verify="" autocomplete="off" placeholder="请简要输入周计划内容" class="layui-input"> -->
                    </div>
                </div>
                <hr style="border:none;border-top-width:5px;border-top-style:solid;border-top-color:#008B8B;" />
                <!--重点工作-->
                <div class="layui-form-item">
                    <label  class="layui-form-label layui-required" >重点工作</label>
                    <div class="layui-input-block" style="width: 666px;">
                        <textarea type="text" style="width:666px!important;" name="zdgzInfo" id="zdgzInfo" value="" lay-verify="" autocomplete="off" placeholder="请输入日常工作内容"  class="layui-textarea"></textarea>
                        <!-- <input style="width:500px!important;" name="weekInfo" id="weekInfo" value=""  type="text" lay-verify="" autocomplete="off" placeholder="请简要输入周计划内容" class="layui-input"> -->
                    </div>
                </div>
                <hr style="border:none;border-top-width:5px;border-top-style:solid;border-top-color:#008B8B;" />
                <!--创新工作-->
                <div class="layui-form-item">
                    <label  class="layui-form-label layui-required" >创新工作</label>
                    <div class="layui-input-block" style="width: 666px;">
                        <textarea type="text" style="width:666px!important;" name="cxgzInfo" id="cxgzInfo" value="" lay-verify="" autocomplete="off" placeholder="请输入日常工作内容"  class="layui-textarea"></textarea>
                        <!-- <input style="width:500px!important;" name="weekInfo" id="weekInfo" value=""  type="text" lay-verify="" autocomplete="off" placeholder="请简要输入周计划内容" class="layui-input"> -->
                    </div>
                </div>
                <hr style="border:none;border-top-width:5px;border-top-style:solid;border-top-color:#008B8B;" />
                <!--其他工作-->
                <div class="layui-form-item">
                    <label  class="layui-form-label layui-required" >其他事项</label>
                    <div class="layui-input-block" style="width: 666px;">
                        <textarea type="text" style="width:666px!important;" name="lsrwInfo" id="lsrwInfo" value="" lay-verify="" autocomplete="off" placeholder="请简要输入临时任务"  class="layui-textarea"></textarea>
                        <!-- <input style="width:500px!important;" name="weekInfo" id="weekInfo" value=""  type="text" lay-verify="" autocomplete="off" placeholder="请简要输入周计划内容" class="layui-input"> -->
                    </div>
                </div>
            </td>
            <!--岗位职责-->
            <td>
                <div id="gwzzInfo">
                </div>
            </td>
        </tr>
        </tbody>

    </table>
    <hr>
    <hr>
    <div class="layui-form-item" style="">
   		<div class="layui-input-inline" style="margin-left:100px">
        	<button class="layui-btn layui-btn-radius" lay-submit lay-filter="edit-week-form" style="width: 110px">更新</button>
       	</div>
 	</div>
    </form>
</div>


</body>
<script type="text/javascript" src="static/js/jquery-3.3.1.js"></script>
<script type="text/javascript" src="static/lib/layui/layui.js"></script>
<script type="text/javascript" src="static/js/xadmin.js"></script>
<script>
    window.onload = function () {
      //加载周记实id
        $("#wId").val(decodeURI(getQueryVariable("wId")));
        $("#finshLivel").val(decodeURI(getQueryVariable("wFinshLivel")));

        //加载周记实信息
        $.ajax({        	
            url:'empWeekInfo/selectVoByPrimaryKey.do',
            dataType:'json',
            data: {"id": parseInt($("#wId").val())},
            type:'post',
            success:function(result){
            	//console.log("result="+JSON.stringify(result));
            	//console.log("wWeekInfo="+JSON.stringify(result.wWeekInfo));
                $("#weekInfo").val(result.wWeekInfo);
                $("#zdgzInfo").val(result.wZdgzInfo);
                $("#cxgzInfo").val(result.wCxgzInfo);
                $("#lsrwInfo").val(result.wTempOraryInfo);


            }
        });

        //加载部门下拉搜索框
        var dId = $("#dId");
        $.ajax({
            url:'department/findSelective.do?page=1&limit=999', //分页限制为999条，就是全部
            dataType:'json',
            type:'post',
            success:function(result){
                $.each(result.data,function(index,item){
                    if(item.dId == $("#wwId").val()) {
                        dId.append("<option checked='checked' value="+item.dId+">"+item.dName+"</option>");
                    } else {
                        dId.append("<option value="+item.dId+">"+item.dName+"</option>");
                    }
                })
                dId.val($("#wwId").val());   //设置选中的值，”“中的值是option中的value值
                layui.form.render('select');  //渲染select
            }
        });


        //初始加载员工个人的岗位职责
        var username = $("#username").val();
        var password = $("#password").val();
        /****/
        //加载周记实信息
        $.ajax({
            data: {
                'username': username,
                'password': password,
            },
            url:'empWeekInfo/selectGwzzinfo.do',
            dataType:'json',
            type:'post',
            success:function(result){
                var content = result.rContent;
                if(content == null || content == "null" || content == ""){
                    $("#gwzzInfo").html("");
                }else{
                    $("#gwzzInfo").html(result.rContent);
                }

            }
        });

    }

    //获取url参数
    function getQueryVariable(variable)
    {
        var query = window.location.search.substring(1);
        var index = query.indexOf("?");
        query = query.substr(index+1,query.length);
        var vars = query.split("&");
        for (var i=0;i<vars.length;i++) {
            var pair = vars[i].split("=");
            if(pair[0] == variable){
                return pair[1];
            }
        }
        return false;
    }

    // 预先加载
    layui.use(['form', 'layedit', 'laydate'], function(){
        var form = layui.form
            ,layer = layui.layer
            ,layedit = layui.layedit
            ,laydate = layui.laydate;

        form.verify({
            length: function(value){
                value = value.replace(" ","");
                if(value.length > 200){
                    return '输入长度过长';
                }
            },
            
            specialCharacter: function(value) {
                // 验证特殊字符
                var pattern = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~！@#￥……&*（）——|{}【】‘；：”“'。，、？]");
                if(pattern.test(value)){
                    return '不能包含特殊字符';
                }
            }
        });

        //监听提交form里面的submit标签
        form.on('submit(edit-week-form)', function (data) {
            $.ajax({
            	url: "empWeekInfo/editWeekInfo.do",
                data: {
                	"wId":parseInt($("#wId").val()),
                    "wWeekInfo":$("#weekInfo").val(),
                    "wZdgzInfo":$("#zdgzInfo").val(),
                    "wCxgzInfo":$("#cxgzInfo").val(),
                    "wTempOraryInfo":$("#lsrwInfo").val(),
                    "wFinshLivel":$("#finshLivel").val()
                },
                type: "post",
                dataType: "json",
                success: function (result) {
                    if (result.code == 100) {
                        layer.alert("修改成功", {title: "修改信息"},
                        		 function () {
                            window.parent.location.reload();
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        }
                        )

                    } else {
                      layer.msg(result.message);
                    }
                },
            })
            return false;
        });
    });



</script>
</html>
